<?php

namespace app\controllers;

use app\components\WebController;

class SiteController extends WebController {

    public function actionIndex() {
        $this->view->title = '首页';
        return '';
    }

    public function actionRefresh() {
        $key = [];
        $key[] = 'yii\widgets\FragmentCache';
        $key[] = 'site/index';
        $key[] = \Yii::$app->user->isGuest;
        return \Yii::$app->cache->delete($key) ? 1 : -1;
    }

    public function actionFlushCache($id = NULL) {
        if (NULL !== $id) {
            return \Yii::$app->cache->delete($id) ? 1 : -1;
        }
        return \Yii::$app->cache->flush() ? 1 : -2;
    }

}